
import java.io.IOException;
import javax.websocket.EncodeException;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
import java.io.IOException;
import javax.websocket.EncodeException;
import javax.websocket.OnMessage;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;
/**
 *
 * @author maantelo
 */
@ServerEndpoint ("/chat")
public class ChatEndpoint {
    @OnMessage
    public void message (String message, Session client) throws IOException, EncodeException
    {
        System.out.println("message endpoint: " + message);
        for (Session peer : client.getOpenSessions()) {
            peer.getBasicRemote().sendText(message );
        }
    }
    
}
